//Note: The returned array must be malloced, assume caller calls free().
//
int* sortedSquares(int* nums, int numsSize, int* returnSize){
	int left = 0;
	int right = numsSize - 1;
	*returnSize = numsSize;
	int* ans = (int*)malloc(sizeof(int)* numsSize);
	int index;
	for (index = numsSize - 1; index >= 0; index--){
		int Isqure = nums[left] * nums[left];
		int Rsqure = nums[right] * nums[right];

		if (Isqure < Rsqure){
			ans[index] = Rsqure;
			right--;
		}

		else if (Isqure >= Rsqure)
		{
			ans[index] = Isqure;
			left++;
		}

	}
	return ans;
}